home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / perl5 / ExtUtils / MakeMaker.pm
Text File  |  1995-07-02  |  19KB  |  695 lines

  1. package ExtUtils::MakeMaker;
  2.  
  3. # Authors: Andy Dougherty    <doughera@lafcol.lafayette.edu>
  4. #       Andreas Koenig    <k@franz.ww.TU-Berlin.DE>
  5. #       Tim Bunce        <Tim.Bunce@ig.co.uk>
  6.  
  7. # Last Revision: 12 Oct 1994
  8.  
  9. # This utility is designed to write a Makefile for an extension 
  10. # module from a Makefile.PL. It is based on the excellent Makefile.SH
  11. # model provided by Andy Dougherty and the perl5-porters. 
  12.  
  13. # It splits the task of generating the Makefile into several
  14. # subroutines that can be individually overridden.
  15. # Each subroutine returns the text it wishes to have written to
  16. # the Makefile.
  17.  
  18. use Config;
  19. require Exporter;
  20. @ISA = qw(Exporter);
  21. @EXPORT = qw(writeMakefile mkbootstrap $Verbose);
  22. @EXPORT_OK = qw(%att @recognized_att_keys);
  23.  
  24. use strict qw(refs);
  25.  
  26. # Setup dummy package:
  27. # MY exists for overriding methods to be defined within
  28. unshift(@MY::ISA, qw(MM));
  29.  
  30. $Verbose = 0;
  31. $Subdirs = 0;    # set to 1 to have this .PL run all below
  32. $^W=1;
  33.  
  34.  
  35. # For most extensions it will do to call
  36. #
  37. #   use ExtUtils::MakeMaker
  38. #   &writeMakefile("potential_libs" => "-L/usr/alpha -lfoo -lbar");
  39. #
  40. # from Makefile.PL in the extension directory
  41. # It is also handy to include some of the following attributes:
  42. #
  43. @recognized_att_keys=qw(
  44.     TOP INC DISTNAME VERSION DEFINE OBJECT LDTARGET ARMAYBE
  45.     BACKUP_LIBS  AUTOSPLITMAXLEN LINKTYPE
  46.     potential_libs otherldflags perl fullperl
  47.     distclean_tarflags
  48.     clean_files realclean_files
  49. );
  50.  
  51. #
  52. # TOP      is the directory above lib/ and ext/ (normally ../..)
  53. #          (MakeMaker will normally work this out for itself)
  54. # INC      is something like "-I/usr/local/Minerva/include"
  55. # DISTNAME is a name of your choice for distributing the package
  56. # VERSION  is your version number
  57. # DEFINE   is something like "-DHAVE_UNISTD_H"
  58. # OBJECT   defaults to '$(BASEEXT).o', but can be a long string containing 
  59. #          all object files, e.g. "tkpBind.o tkpButton.o tkpCanvas.o"
  60. # LDTARGET defaults to $(OBJECT) and is used in the ld command
  61. #          (some machines need additional switches for bigger projects)
  62. # ARMAYBE  defaults to ":", but can be used to run ar before ld
  63. # BACKUP_LIBS is an anonymous array of libraries to be searched for
  64. #          until we get at least some output from ext/util/extliblist
  65. #          'potential_libs' => "-lgdbm",
  66. #          'BACKUP_LIBS' => [ "-ldbm -lfoo", "-ldbm.nfs" ]
  67. # AUTOSPLITMAXLEN defaults to 8 and is used when autosplit is done
  68. #          (can be set higher on a case-by-case basis)
  69. # defaults to `dynamic', can be set to `static'
  70.  
  71. #
  72. # `make distclean'  builds $(DISTNAME)-$(VERSION).tar.Z after a clean
  73.  
  74. # Be aware, that you can also pass attributes into the %att hash table
  75. # by calling Makefile.PL with an argument of the form TOP=/some/where.
  76.  
  77. # If the Makefile generated by default does not fit your purpose,
  78. # you may specify private subroutines in the Makefile.PL as there are:
  79. #
  80. # MY->initialize        =>   sub MY::initialize{ ... }
  81. # MY->post_initialize   =>   sub MY::post_initialize{ ... }
  82. # MY->constants         =>   etc
  83. # MY->dynamic
  84. # etc. (see function writeMakefile, for the current breakpoints)
  85. #
  86. # Each subroutines returns the text it wishes to have written to
  87. # the Makefile. To override a section of the Makefile you can
  88. # either say:     sub MY::co { "new literal text" }
  89. # or you can edit the default by saying something like:
  90. #    sub MY::co { $_=MM->co; s/old text/new text/; $_ }
  91. #
  92. # If you still need a different solution, try to develop another 
  93. # subroutine, that fits your needs and submit the diffs to 
  94. # perl5-porters or comp.lang.perl as appropriate.
  95.  
  96. sub writeMakefile {
  97.     %att = @_;
  98.     local($\)="\n";
  99.  
  100.     foreach (@ARGV){
  101.     $att{$1}=$2 if m/(.*)=(.*)/;
  102.     }
  103.     print STDOUT "MakeMaker" if $Verbose;
  104.     print STDOUT map("    $_ = '$att{$_}'\n", sort keys %att) if ($Verbose && %att);
  105.  
  106.     MY->initialize();
  107.  
  108.     print STDOUT "Writing ext/$att{FULLEXT}/Makefile (with variable substitutions)";
  109.  
  110.     open MAKE, ">Makefile" or die "Unable to open Makefile: $!";
  111.  
  112.     MY->mkbootstrap(split(" ", $att{'dynaloadlibs'}));
  113.     print MAKE MY->post_initialize;
  114.  
  115.     print MAKE MY->constants;
  116.     print MAKE MY->post_constants;
  117.  
  118.     print MAKE MY->subdir if $Subdirs;
  119.     print MAKE MY->dynamic;
  120.     print MAKE MY->force;
  121.     print MAKE MY->static;
  122.     print MAKE MY->co;
  123.     print MAKE MY->c;
  124.     print MAKE MY->installpm;
  125.     print MAKE MY->clean;
  126.     print MAKE MY->realclean;
  127.     print MAKE MY->test;
  128.     print MAKE MY->install;
  129.     print MAKE MY->perldepend;
  130.     print MAKE MY->distclean;
  131.     print MAKE MY->postamble;
  132.  
  133.     MY->finish;
  134.  
  135.     close MAKE;
  136.  
  137.     1;
  138. }
  139.  
  140.  
  141. sub mkbootstrap{
  142.     MY->mkbootstrap(@_)
  143. }
  144.  
  145.  
  146. sub avoid_typo_warnings{
  147.     local($t) = "$t
  148.     $main::writeMakefile
  149.     $main::mkbootstrap
  150.     $main::Verbose
  151.     $DynaLoader::dl_resolve_using
  152.     $ExtUtils::MakeMaker::Config
  153.     $DynaLoader::Config
  154.     ";
  155. }
  156.  
  157.  
  158. # --- Supply the MakeMaker default methods ---
  159.  
  160. package MM;
  161.  
  162. use Config;
  163. require Exporter;
  164.  
  165. Exporter::import('ExtUtils::MakeMaker', qw(%att @recognized_att_keys));
  166.  
  167. # These attributes cannot be overridden
  168. @other_att_keys=qw(extralibs dynaloadlibs statloadlibs bootdep);
  169.  
  170.  
  171. sub find_perl{
  172.     my($self, $ver, $names, $dirs, $trace) = @_;
  173.     my($name, $dir);
  174.     print "Looking for perl $ver by these names: @$names, in these dirs: @$dirs\n"
  175.     if ($trace);
  176.     foreach $dir (@$dirs){
  177.     foreach $name (@$names){
  178.         print "checking $dir/$name\n" if ($trace >= 2);
  179.         next unless -x "$dir/$name";
  180.         print "executing $dir/$name\n" if ($trace);
  181.         my($out) = `$dir/$name -e 'require $ver; print "5OK\n" ' 2>&1`;
  182.         return "$dir/$name" if $out =~ /5OK/;
  183.     }
  184.     }
  185.     warn "Unable to find a perl $ver (by these names: @$names, in these dirs: @$dirs)\n";
  186.     0; # false and not empty
  187. }
  188.  
  189.  
  190. sub initialize {
  191.     # Find out directory name.  This is also the extension name.
  192.     chop($pwd=`pwd`);
  193.  
  194.     unless ( $top = $att{TOP} ){
  195.     foreach(qw(../.. ../../.. ../../../..)){
  196.         ($top=$_, last) if -f "$_/config.sh";
  197.     }
  198.     die "Can't find config.sh" unless -f "$top/config.sh";
  199.     }
  200.     chdir $top or die "Couldn't chdir $top: $!";
  201.     chop($abstop=`pwd`);
  202.     chdir $pwd;
  203.  
  204.     # EXTMODNAME = The perl module name for this extension.
  205.     # FULLEXT = Full pathname to extension directory.
  206.     # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  207.     # ROOTEXT = Directory part of FULLEXT. May be empty.
  208.     my($p) = $pwd; $p =~ s:^\Q$abstop/ext/\E::;
  209.     ($att{EXTMODNAME}=$p) =~ s#/#::#g ;        #eg. BSD::Foo::Socket
  210.     ($att{FULLEXT}   =$p);            #eg. BSD/Foo/Socket
  211.     ($att{BASEEXT}   =$p) =~ s:.*/:: ;        #eg. Socket
  212.     ($att{ROOTEXT}   =$p) =~ s:/?\Q$att{BASEEXT}\E$:: ; #eg. BSD/Foo
  213.  
  214.     # Find Perl 5. The only contract here is that both 'perl' and 'fullperl'
  215.     # will be working versions of perl 5.
  216.     $att{'perl'} = MY->find_perl(5.0, [ qw(perl5 perl miniperl) ],
  217.                 [ $abstop, split(":", $ENV{PATH}) ], 0 )
  218.         unless ($att{'perl'} && -x $att{'perl'});
  219.  
  220.     # Define 'fullperl' to be a non-miniperl (used in test: target)
  221.     ($att{'fullperl'} = $att{'perl'}) =~ s/miniperl$/perl/
  222.     unless ($att{'fullperl'} && -x $att{'fullperl'});
  223.  
  224.     for $key (@recognized_att_keys, @other_att_keys){
  225.     # avoid warnings for uninitialized vars
  226.     $att{$key} = "" unless defined $att{$key};
  227.     }
  228.  
  229.     # compute extralibs, dynaloadlibs and statloadlibs from
  230.     # $att{'potential_libs'}
  231.  
  232.     unless ( &run_extliblist($att{'potential_libs'}) ){
  233.        foreach ( @{$att{'BACKUP_LIBS'} || []} ){
  234.            #  Try again.  Maybe they have specified some other libraries
  235.            last if  &run_extliblist($_);
  236.        }
  237.     }
  238. }
  239.  
  240.  
  241. sub run_extliblist {
  242.     my($potential_libs)=@_;
  243.     # Now run ext/util/extliblist to discover what *libs definitions
  244.     # are required for the needs of $potential_libs
  245.     $ENV{'potential_libs'} = $potential_libs;
  246.     $_=`. $abstop/ext/util/extliblist;
  247.     echo extralibs=\$extralibs
  248.     echo dynaloadlibs=\$dynaloadlibs
  249.     echo statloadlibs=\$statloadlibs
  250.     echo bootdep=\$bootdep
  251.     `;
  252.     my(@w);
  253.     foreach $line (split "\n", $_){
  254.     chomp $line;
  255.     if ($line =~ /(.*)\s*=\s*(.*)$/){
  256.         $att{$1} = $2;
  257.         print STDERR "    $1 = $2" if $Verbose;
  258.     }else{
  259.         push(@w, $line);
  260.     }
  261.     }
  262.     print STDERR "Messages from extliblist:\n", join("\n",@w,'')
  263.        if @w ;
  264.     join '', @att{qw(extralibs dynaloadlibs statloadlibs)};
  265. }
  266.  
  267.  
  268. sub post_initialize{
  269.     "";
  270. }
  271.  
  272.  
  273. sub constants {
  274.     my(@m);
  275.  
  276.     $att{BOOTDEP}  = (-f "$att{BASEEXT}_BS") ? "$att{BASEEXT}_BS" : "";
  277.     $att{OBJECT}   = '$(BASEEXT).o' unless $att{OBJECT};
  278.     $att{LDTARGET} = '$(OBJECT)'    unless $att{LDTARGET};
  279.     $att{ARMAYBE}  = ":"            unless $att{ARMAYBE};
  280.     $att{AUTOSPLITMAXLEN} = 8       unless $att{AUTOSPLITMAXLEN};
  281.     $att{LINKTYPE} = ($Config{'usedl'}) ? 'dynamic' : 'static'
  282.     unless $att{LINKTYPE};
  283.  
  284.  
  285.     push @m, "
  286. #
  287. # This Makefile is for the $att{FULLEXT} extension to perl.
  288. # It was written by Makefile.PL, so don't edit it, edit
  289. # Makefile.PL instead. ANY CHANGES MADE HERE WILL BE LOST!
  290.  
  291. DISTNAME = $att{DISTNAME}
  292. VERSION = $att{VERSION}
  293.  
  294. TOP = $top
  295. ABSTOP = $abstop
  296. PERL = $att{'perl'}
  297. FULLPERL = $att{'fullperl'}
  298. INC = $att{INC}
  299. DEFINE = $att{DEFINE}
  300. OBJECT = $att{OBJECT}
  301. LDTARGET = $att{LDTARGET}
  302. ";
  303.  
  304.     push @m, "
  305. CC = $Config{'cc'}
  306. LIBC = $Config{'libc'}
  307. LDFLAGS = $Config{'ldflags'}
  308. CLDFLAGS = $Config{'ldflags'}
  309. LINKTYPE = $att{LINKTYPE}
  310. ARMAYBE = $att{ARMAYBE}
  311. RANLIB = $Config{'ranlib'}
  312.  
  313. SMALL = $Config{'small'}
  314. LARGE = $Config{'large'} $Config{'split'}
  315. # The following are used to build and install shared libraries for
  316. # dynamic loading.
  317. LDDLFLAGS = $Config{'lddlflags'}
  318. CCDLFLAGS = $Config{'ccdlflags'}
  319. CCCDLFLAGS = $Config{'cccdlflags'}
  320. SO = $Config{'so'}
  321. DLEXT = $Config{'dlext'}
  322. DLSRC = $Config{'dlsrc'}
  323. ";
  324.  
  325.     push @m, "
  326. # $att{FULLEXT} might need to be linked with some extra libraries.
  327. # EXTRALIBS =  full list of libraries needed for static linking.
  328. #        Only those libraries that actually exist are included.
  329. # DYNALOADLIBS = list of those libraries that are needed but can be
  330. #        linked in dynamically on this platform.  On SunOS, for
  331. #        example, this would be .so* libraries, but not archive
  332. #        libraries.  The bootstrap file is installed only if
  333. #        this list is not empty.
  334. # STATLOADLIBS = list of those libraries which must be statically
  335. #        linked into the shared library.  On SunOS 4.1.3, 
  336. #        for example,  I have only an archive version of
  337. #        -lm, and it must be linked in statically.
  338. EXTRALIBS = $att{'extralibs'}
  339. DYNALOADLIBS = $att{'dynaloadlibs'}
  340. STATLOADLIBS = $att{'statloadlibs'}
  341.  
  342. ";
  343.  
  344.     push @m, "
  345. # EXTMODNAME = The perl module name for this extension.
  346. # FULLEXT = Full pathname to extension directory.
  347. # BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT.
  348. # ROOTEXT = Directory part of FULLEXT. May be empty.
  349. EXTMODNAME = $att{EXTMODNAME}
  350. FULLEXT = $att{FULLEXT}
  351. BASEEXT = $att{BASEEXT}
  352. ROOTEXT = $att{ROOTEXT}
  353. # and for backward compatibility and for AIX support (due to change!)
  354. EXT = $att{BASEEXT}
  355.  
  356. # $att{FULLEXT} might have its own typemap
  357. EXTTYPEMAP = ".(-f "typemap" ? "typemap" : "")."
  358. # $att{FULLEXT} might have its own bootstrap support
  359. BOOTSTRAP = $att{BASEEXT}.bs
  360. BOOTDEP = $att{BOOTDEP}
  361. ";
  362.  
  363.     push @m, '
  364. # Where to put things:
  365. AUTO = $(TOP)/lib/auto
  366. AUTOEXT = $(TOP)/lib/auto/$(FULLEXT)
  367. INST_BOOT = $(AUTOEXT)/$(BASEEXT).bs
  368. INST_DYNAMIC = $(AUTOEXT)/$(BASEEXT).$(DLEXT)
  369. INST_STATIC = $(BASEEXT).a
  370. INST_PM = $(TOP)/lib/$(FULLEXT).pm
  371. '."
  372. # These two are only used by install: targets
  373. INSTALLPRIVLIB = $Config{'installprivlib'}
  374. INSTALLARCHLIB = $Config{'installarchlib'}
  375. ";
  376.  
  377.     push @m, "\nshellflags = $Config{'shellflags'}" if $Config{'shellflags'};
  378.  
  379.     push @m, q{
  380. # Tools
  381. SHELL = /bin/sh
  382. CCCMD = `sh $(shellflags) $(ABSTOP)/cflags $@`
  383. XSUBPP = $(TOP)/ext/xsubpp
  384. # the following is a portable way to say mkdir -p
  385. MKPATH = $(PERL) -we '$$"="/"; foreach(split(/\//,$$ARGV[0])){ push(@p, $$_); next if -d "@p"; print "mkdir @p\n"; mkdir("@p",0777)||die "mkdir @p: $$!" } exit 0;'
  386. AUTOSPLITLIB = cd $(TOP); \
  387.     $(PERL) -Ilib -e 'use AutoSplit; $$AutoSplit::Maxlen=}.$att{AUTOSPLITMAXLEN}.q{; autosplit_lib_modules(@ARGV) ;'
  388. };
  389.  
  390.     push @m, '
  391.  
  392. all :: 
  393.  
  394. config :: Makefile
  395.     @$(MKPATH) $(AUTOEXT)
  396.  
  397. install ::
  398.  
  399. ';
  400.  
  401.     join('',@m);
  402. }
  403.  
  404.  
  405. sub post_constants{
  406.     "";
  407. }
  408.  
  409.  
  410. sub subdir {
  411.     my(@m);
  412.     foreach $MakefilePL (<*/Makefile.PL>){
  413.     ($subdir=$MakefilePL) =~ s:/Makefile\.PL$:: ;
  414.     push @m, "
  415. config ::
  416.     \@cd $subdir ; \\
  417.     if test ! -f Makefile; then \\
  418.     test -f Makefile.PL  && \$(PERL) -I\$(ABSTOP)/lib Makefile.PL TOP=\$(ABSTOP) ; \\
  419.     fi
  420.  
  421. all ::
  422.     cd $subdir ; \$(MAKE) config
  423.     cd $subdir ; \$(MAKE) all
  424. ";
  425.  
  426.     }
  427.     join('',@m);
  428. }
  429.  
  430.  
  431. sub co {
  432.     '
  433. .c.o:
  434.     $(CCCMD) $(CCCDLFLAGS) $(DEFINE) -I$(TOP) $(INC) $*.c
  435. ';
  436. }
  437.  
  438.  
  439. sub force {
  440.     '
  441. # Phony target to force checking subdirectories.
  442. FORCE:
  443. ';
  444. }
  445.  
  446.  
  447. sub dynamic {
  448.     '
  449. all::    $(LINKTYPE)
  450.  
  451. # Target for Dynamic Loading:
  452. dynamic::    $(INST_DYNAMIC) $(INST_PM) $(INST_BOOT)
  453.  
  454. $(INST_DYNAMIC): $(OBJECT)
  455.     @$(MKPATH) $(AUTOEXT)
  456.     $(ARMAYBE) cr $(EXTMODNAME).a $(OBJECT) 
  457.     ld $(LDDLFLAGS) -o $@ $(LDTARGET) '.$att{'otherldflags'}.' $(STATLOADLIBS)
  458.  
  459. $(BOOTSTRAP): $(BOOTDEP)
  460.     $(PERL) -I$(TOP)/lib -e \'use ExtUtils::MakeMaker; &mkbootstrap("$(DYNALOADLIBS)");\'
  461.     touch $(BOOTSTRAP)
  462.  
  463. $(INST_BOOT): $(BOOTSTRAP)
  464.     @test ! -s $(BOOTSTRAP) || cp $(BOOTSTRAP) $@
  465. ';
  466. }
  467.  
  468.  
  469. sub static {
  470.     '
  471. # Target for Static Loading:
  472. static:: $(INST_STATIC) $(INST_PM)
  473.  
  474. $(INST_STATIC): $(OBJECT)
  475.     ar cr $@ $(OBJECT)
  476.     $(RANLIB) $@
  477.     echo $(EXTRALIBS) >> $(TOP)/ext.libs
  478. ';
  479. }
  480.  
  481.  
  482. sub c {
  483.     '
  484. $(BASEEXT).c:    $(BASEEXT).xs $(XSUBPP) $(TOP)/ext/typemap $(EXTTYPEMAP) $(TOP)/cflags
  485.     $(PERL) $(XSUBPP) $(BASEEXT).xs >tmp
  486.     mv tmp $@
  487. ';
  488. }
  489.  
  490.  
  491. sub installpm {
  492.     '
  493. $(INST_PM):    $(BASEEXT).pm
  494.     @$(MKPATH) $(TOP)/lib/$(ROOTEXT)
  495.     rm -f $@
  496.     cp $(BASEEXT).pm $@
  497.     @$(AUTOSPLITLIB) $(EXTMODNAME)
  498. ';
  499. }
  500.  
  501.  
  502. sub clean {
  503.     '
  504. clean::
  505.     rm -f *.o *.a mon.out core $(BASEEXT).c so_locations
  506.     rm -f makefile Makefile $(BOOTSTRAP) $(BASEEXT).bso '.$att{'clean_files'}.'
  507. ';
  508. }
  509.  
  510.  
  511. sub realclean {
  512.     '
  513. realclean::     clean
  514.     rm -f $(INST_DYNAMIC) $(INST_STATIC) $(INST_BOOT)
  515.     rm -rf $(INST_PM) $(AUTOEXT) '.$att{'realclean_files'}.'
  516.  
  517. purge:    realclean
  518. ';
  519. }
  520.  
  521.  
  522. sub test {
  523.     '
  524. test: all
  525.     $(FULLPERL) -I$(TOP)/lib -e \'use Test::Harness; runtests @ARGV;\' t/*.t
  526. ';
  527. }
  528.  
  529.  
  530. sub install {
  531.     '
  532. # used if installperl will not be installing it for you
  533. install:: all
  534.     # not yet defined
  535. ';
  536. }
  537.  
  538.  
  539. sub distclean {
  540.     my($tarflags) = $att{'distclean_tarflags'} || 'cvf';
  541.     '
  542. distclean:     clean
  543.     rm -f Makefile *~ t/*~
  544.     cd ..; tar '.$tarflags.' "$(DISTNAME)-$(VERSION).tar" $(BASEEXT)
  545.     cd ..; compress "$(DISTNAME)-$(VERSION).tar"
  546. ';
  547. }
  548.  
  549.  
  550. sub perldepend {
  551.     '
  552. $(OBJECT) : Makefile
  553. $(OBJECT) : $(TOP)/EXTERN.h
  554. $(OBJECT) : $(TOP)/INTERN.h
  555. $(OBJECT) : $(TOP)/XSUB.h
  556. $(OBJECT) : $(TOP)/av.h
  557. $(OBJECT) : $(TOP)/cop.h
  558. $(OBJECT) : $(TOP)/cv.h
  559. $(OBJECT) : $(TOP)/dosish.h
  560. $(OBJECT) : $(TOP)/embed.h
  561. $(OBJECT) : $(TOP)/form.h
  562. $(OBJECT) : $(TOP)/gv.h
  563. $(OBJECT) : $(TOP)/handy.h
  564. $(OBJECT) : $(TOP)/hv.h
  565. $(OBJECT) : $(TOP)/keywords.h
  566. $(OBJECT) : $(TOP)/mg.h
  567. $(OBJECT) : $(TOP)/op.h
  568. $(OBJECT) : $(TOP)/opcode.h
  569. $(OBJECT) : $(TOP)/patchlevel.h
  570. $(OBJECT) : $(TOP)/perl.h
  571. $(OBJECT) : $(TOP)/perly.h
  572. $(OBJECT) : $(TOP)/pp.h
  573. $(OBJECT) : $(TOP)/proto.h
  574. $(OBJECT) : $(TOP)/regcomp.h
  575. $(OBJECT) : $(TOP)/regexp.h
  576. $(OBJECT) : $(TOP)/scope.h
  577. $(OBJECT) : $(TOP)/sv.h
  578. $(OBJECT) : $(TOP)/unixish.h
  579. $(OBJECT) : $(TOP)/util.h
  580. $(TOP)/config.h:        $(TOP)/config.sh; cd $(TOP); /bin/sh config_h.SH
  581. $(TOP)/embed.h: $(TOP)/config.sh; cd $(TOP); /bin/sh embed_h.SH
  582. $(TOP)/cflags:  $(TOP)/config.sh; cd $(TOP); /bin/sh cflags.SH
  583.  
  584. Makefile:    Makefile.PL
  585.     $(PERL) -I$(TOP)/lib Makefile.PL
  586. ';
  587. }
  588.  
  589.  
  590. sub postamble{
  591.     "";
  592. }
  593.  
  594.  
  595. sub finish {
  596.     chmod 0644, "Makefile";
  597.     system("$Config{'eunicefix'} Makefile") unless $Config{'eunicefix'} eq ":";
  598. }
  599.  
  600.  
  601.  
  602. sub mkbootstrap {
  603. #
  604. # mkbootstrap, by:
  605. #
  606. #    Andreas Koenig <k@otto.ww.TU-Berlin.DE>
  607. #    Tim Bunce <Tim.Bunce@ig.co.uk>
  608. #    Andy Dougherty <doughera@lafcol.lafayette.edu>
  609. #
  610. #  This perl script attempts to make a bootstrap file for use by this
  611. #  system's DynaLoader. It typically gets called from an extension
  612. #  Makefile.
  613. #
  614. # There is no .bs file supplied with the extension. Instead a _BS
  615. # file which has code for the special cases, like posix for berkeley db
  616. # on the NeXT.
  617. # This file will get parsed, and produce a maybe empty
  618. # @DynaLoader::dl_resolve_using array for the current architecture.
  619. # That will be extended by $dynaloadlibs, which was computed by Andy's
  620. # extliblist script. If this array still is empty, we do nothing, else
  621. # we write a .bs file with an @DynaLoader::dl_resolve_using array, but
  622. # without any `if's, because there is no longer a need to deal with
  623. # special cases.
  624. # The _BS file can put some code into the generated .bs file by placing
  625. # it in $bscode. This is a handy 'escape' mechanism that may prove
  626. # useful in complex situations.
  627. # If @DynaLoader::dl_resolve_using contains -L* or -l* entries then
  628. # mkbootstrap will automatically add a dl_findfile() call to the
  629. # generated .bs file.
  630. #
  631.     my($self, @dynaloadlibs)=@_;
  632.     print STDERR "    dynaloadlibs=@dynaloadlibs" if $Verbose;
  633.     require DynaLoader; # we need DynaLoader, if the *_BS gets interpreted
  634.     import DynaLoader;  # we don't say `use', so if DynaLoader is not 
  635.               # yet built MakeMaker works nonetheless except here
  636.  
  637.     &initialize unless defined $att{'perl'};
  638.  
  639.     rename "$att{BASEEXT}.bs", "$att{BASEEXT}.bso";
  640.  
  641.     if (-f "$att{BASEEXT}_BS"){
  642.     $_ = "$att{BASEEXT}_BS";
  643.     package DynaLoader; # execute code as if in DynaLoader
  644.     local($osname, $dlsrc) = (); # avoid warnings
  645.     ($osname, $dlsrc) = @Config{qw(osname dlsrc)};
  646.     $bscode = "";
  647.     unshift @INC, ".";
  648.     require $_;
  649.     }
  650.  
  651.     if ($Config{'dlsrc'} =~ /^dl_dld/){
  652.     package DynaLoader;
  653.     push(@dl_resolve_using, dl_findfile('-lc'));
  654.     }
  655.  
  656.     my(@all) = (@dynaloadlibs, @DynaLoader::dl_resolve_using);
  657.     my($method) = '';
  658.     if (@all){
  659.     open BS, ">$att{BASEEXT}.bs"
  660.         or die "Unable to open $att{BASEEXT}.bs: $!";
  661.     print STDOUT "Writing $att{BASEEXT}.bs\n";
  662.     print STDOUT "    containing: @all" if $Verbose;
  663.     print BS "# $att{BASEEXT} DynaLoader bootstrap file for $Config{'osname'} architecture.\n";
  664.     print BS "# Do not edit this file, changes will be lost.\n";
  665.     print BS "# This file was automatically generated by the\n";
  666.     print BS "# mkbootstrap routine in ExtUtils/MakeMaker.pm.\n";
  667.     print BS "\@DynaLoader::dl_resolve_using = ";
  668.     if (" @all" =~ m/ -[lL]/){
  669.         print BS "  dl_findfile(qw(\n  @all\n  ));\n";
  670.     }else{
  671.         print BS "  qw(@all);\n";
  672.     }
  673.     # write extra code if *_BS says so
  674.     print BS $DynaLoader::bscode if $DynaLoader::bscode;
  675.     print BS "1;\n";
  676.     close BS;
  677.     }
  678.  
  679.     if ($Config{'dlsrc'} =~ /^dl_aix/){
  680.        open AIX, ">$att{BASEEXT}.exp";
  681.        print AIX "#!\nboot_$att{BASEEXT}\n";
  682.        close AIX;
  683.     }
  684. }
  685.  
  686. # the following makes AutoSplit happy (bug in perl5b3e)
  687. package ExtUtils::MakeMaker;
  688. 1;
  689.  
  690. __END__
  691.